package com.bdqn.Practice.controller;

import com.bdqn.Practice.mapper.StorageRecordMapper;
import com.bdqn.Practice.service.StorageRecordService;
import com.bdqn.Practice.service.SupplierService;
import com.bdqn.Practice.service.SysRoleService;
import com.bdqn.Practice.util.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

@Controller
@RequestMapping("/storageRecord")
public class StorageRecordMapperController {
    @Resource
    private SupplierService supplierService;
    @Resource
    private StorageRecordService service;

    @GetMapping(value = "list")
    public String userList(Model model, @RequestParam(defaultValue = "1") Integer pageIndex,String queryGoodsName,Integer querySupplierId){
        Page page=new Page();
        page.setTotalCount(service.count());
        page.setCurrentPageNo(pageIndex);
        page.setList(service.selectPageList(page.getCurrentPageNo(),page.getPageSize(),queryGoodsName,querySupplierId));
        model.addAttribute("supplierList",supplierService.selectSupName());

        model.addAttribute("storageRecordList",page.getList());
        model.addAttribute("page",page);
        return "storageRecord/list";
    }


}
